﻿using System.Data.Entity.ModelConfiguration;

using NeGroid.ChampionshipManager.Core;

namespace NeGroid.ChampionshipManager.Persistance.Mappings
{
	public class PlayerMap : EntityTypeConfiguration<Player>
	{
		public PlayerMap()
		{
			HasKey(t => t.Id);

			Property(t => t.FirstName)
				.HasMaxLength(100)
				.IsRequired();
			Property(t => t.LastName)
				.HasMaxLength(100)
				.IsRequired();
			Property(t => t.MiddleName)
				.HasMaxLength(100)
				.IsRequired();

			HasOptional(t => t.Team)
				.WithMany(t => t.Players)
                .HasForeignKey(t => t.TeamId);

			ToTable("Players");
		}
	}
}
